﻿Imports System.Data.OleDb
Partial Public Class topRated
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        'Dim dbconn = New OleDbConnection(ConfigurationManager.ConnectionStrings _
        '                   ("ConnectionString").ToString())
        'dbconn.Open()
        'getaverageuserrating(dbconn)
    End Sub

    'Protected Function getaverageuserrating(ByVal dbconn As OleDbConnection)

    '    Dim averagesql As String = "SELECT UserRatings.FK_MaterialName, UserRatings.UserRate, MaterialCollection.ID FROM MaterialCollection INNER JOIN UserRatings ON MaterialCollection.[ID] = UserRatings.[FK_MaterialName]"
    '    Dim averagecmd As New OleDbCommand(averagesql, dbconn)
    '    Dim averageread = averagecmd.ExecuteReader()
    '    averageread.Read()
    '    'Try
    '    '    Return CInt(averageread("ratingAverage"))
    '    'Catch ex As Exception
    '    '    Return 0
    '    'End Try
    'End Function

    Protected Sub GridView1_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles GridView1.RowCommand
        If e.CommandName = "View" Then

            Dim index As Integer = Convert.ToInt32(e.CommandArgument)

            Response.Redirect("details.aspx?materialID=" & GridView1.DataKeys(index).Value.ToString())
        End If
    End Sub
End Class